<template>
  <!-- 地图量算 -->
  <div class="measure-map">
    <div class="map-box">
      <div id="container" class="container"></div>
      <div class="input-card">
        <el-cascader
          v-model="value"
          :options="options"
          @change="handleChange"
        ></el-cascader>
      </div>
    </div>
  </div>
</template>

<script
  type="text/javascript"
  src="https://webapi.amap.com/maps?v=1.4.15&key=84f61226c5c3819011a303ef5c321e5f&plugin=AMap.MouseTool,AMap.HawkEye,AMap.DistrictSearch,AMap.Scale,AMap.ToolBar,AMap.ControlBar,AMap.ImageLayer"
></script>
<script>
export default {
  data() {
    return {
      map: null,
      mouseTool: null,
      radios: null,
      options: [],
      value: null,
      cityData: [
        {
          Mcity: "四川省",
          city: "成都市",
          address: "成都市",
          jing: 104.066541,
          wei: 30.572269,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "锦江区",
          jing: 104.080989,
          wei: 30.657689,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "青羊区",
          jing: 104.062499,
          wei: 30.674406,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "金牛区",
          jing: 104.117422,
          wei: 30.763102,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "武侯区",
          jing: 104.04339,
          wei: 30.641982,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "成华区",
          jing: 104.101255,
          wei: 30.660122,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "龙泉驿区",
          jing: 104.274632,
          wei: 30.556507,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "青白江区",
          jing: 104.250877,
          wei: 30.878681,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "新都区",
          jing: 104.158705,
          wei: 30.823499,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "温江区",
          jing: 103.837104,
          wei: 30.69046,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "双流区",
          jing: 103.951908,
          wei: 30.333027,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "郫都区",
          jing: 103.901092,
          wei: 30.795854,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "金堂县",
          jing: 104.412005,
          wei: 30.862017,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "郫县",
          jing: 103.886629,
          wei: 30.808481,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "大邑县",
          jing: 103.511875,
          wei: 30.572269,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "蒲江县",
          jing: 103.506498,
          wei: 30.196789,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "新津县",
          jing: 103.811345,
          wei: 30.410222,
        },
        {
          Mcity: "四川省",
          city: "都江堰市",
          address: "都江堰市",
          jing: 103.650219,
          wei: 30.975943,
        },
        {
          Mcity: "四川省",
          city: "彭州市",
          address: "彭州市",
          jing: 103.958013,
          wei: 30.990165,
        },
        {
          Mcity: "四川省",
          city: "邛崃市",
          address: "邛崃市",
          jing: 103.464156,
          wei: 30.410275,
        },
        {
          Mcity: "四川省",
          city: "崇州市",
          address: "崇州市",
          jing: 103.673001,
          wei: 30.630122,
        },
        {
          Mcity: "四川省",
          city: "简阳市",
          address: "简阳市",
          jing: 104.546773,
          wei: 30.410754,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "自贡市",
          jing: 104.778442,
          wei: 29.33903,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "自流井区",
          jing: 104.777191,
          wei: 29.33743,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "贡井区",
          jing: 104.715117,
          wei: 29.345546,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "大安区",
          jing: 104.773968,
          wei: 29.363634,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "沿滩区",
          jing: 104.874073,
          wei: 29.272581,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "荣县",
          jing: 104.417388,
          wei: 29.44541,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "富顺县",
          jing: 104.975048,
          wei: 29.18143,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "攀枝花市",
          jing: 101.718637,
          wei: 26.582347,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "仁和区",
          jing: 101.738528,
          wei: 26.497765,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "米易县",
          jing: 102.110339,
          wei: 26.890689,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "盐边县",
          jing: 101.855071,
          wei: 26.683213,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "泸州市",
          jing: 105.442258,
          wei: 28.87181,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "江阳区",
          jing: 105.435009,
          wei: 28.878818,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "纳溪区",
          jing: 105.371151,
          wei: 28.773428,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "龙马潭区",
          jing: 105.437765,
          wei: 28.913221,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "泸县",
          jing: 105.381893,
          wei: 29.151534,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "合江县",
          jing: 105.831067,
          wei: 28.811203,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "叙永县",
          jing: 105.444765,
          wei: 28.155801,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "古蔺县",
          jing: 105.812602,
          wei: 28.038802,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "德阳市",
          jing: 104.397894,
          wei: 31.126855,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "旌阳区",
          jing: 104.416943,
          wei: 31.142498,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "罗江区",
          jing: 104.510249,
          wei: 31.317045,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "中江县",
          jing: 104.678749,
          wei: 31.033051,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "罗江县",
          jing: 104.510249,
          wei: 31.317045,
        },
        {
          Mcity: "四川省",
          city: "广汉市",
          address: "广汉市",
          jing: 104.282331,
          wei: 30.976165,
        },
        {
          Mcity: "四川省",
          city: "什邡市",
          address: "什邡市",
          jing: 104.167501,
          wei: 31.12678,
        },
        {
          Mcity: "四川省",
          city: "绵竹市",
          address: "绵竹市",
          jing: 104.22075,
          wei: 31.338077,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "绵阳市",
          jing: 104.679114,
          wei: 31.46745,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "涪城区",
          jing: 104.750215,
          wei: 31.47083,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "游仙区",
          jing: 104.766393,
          wei: 31.473779,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "安州区",
          jing: 104.567187,
          wei: 31.534886,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "三台县",
          jing: 105.094586,
          wei: 31.095979,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "盐亭县",
          jing: 105.389453,
          wei: 31.208363,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "梓潼县",
          jing: 105.170845,
          wei: 31.642718,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "北川羌族自治县",
          jing: 104.46797,
          wei: 31.617203,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "北川县",
          jing: 104.46797,
          wei: 31.617203,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "平武县",
          jing: 104.555583,
          wei: 32.409675,
        },
        {
          Mcity: "四川省",
          city: "江油市",
          address: "江油市",
          jing: 104.745877,
          wei: 31.778025,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "广元市",
          jing: 105.843357,
          wei: 32.435435,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "利州区",
          jing: 105.845218,
          wei: 32.433898,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "昭化区",
          jing: 105.964121,
          wei: 32.322788,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "朝天区",
          jing: 105.890445,
          wei: 32.643982,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "旺苍县",
          jing: 106.289905,
          wei: 32.228917,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "青川县",
          jing: 105.238842,
          wei: 32.575485,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "剑阁县",
          jing: 105.524766,
          wei: 32.287723,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "苍溪县",
          jing: 105.934801,
          wei: 31.732432,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "遂宁市",
          jing: 105.592898,
          wei: 30.532847,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "船山区",
          jing: 105.568297,
          wei: 30.525475,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "安居区",
          jing: 105.456342,
          wei: 30.355379,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "蓬溪县",
          jing: 105.70757,
          wei: 30.757575,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "射洪县",
          jing: 105.388405,
          wei: 30.870986,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "大英县",
          jing: 105.236904,
          wei: 30.594337,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "内江市",
          jing: 105.058433,
          wei: 29.580228,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "东兴区",
          jing: 105.07549,
          wei: 29.592756,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "威远县",
          jing: 104.668879,
          wei: 29.52744,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "资中县",
          jing: 104.851944,
          wei: 29.764059,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "乐山市",
          jing: 103.765568,
          wei: 29.552106,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "市中区",
          jing: 103.76133,
          wei: 29.555375,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "沙湾区",
          jing: 103.549991,
          wei: 29.413091,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "五通桥区",
          jing: 103.818009,
          wei: 29.406932,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "金口河区",
          jing: 103.078621,
          wei: 29.244345,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "犍为县",
          jing: 103.949326,
          wei: 29.208171,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "井研县",
          jing: 104.069726,
          wei: 29.651287,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "夹江县",
          jing: 103.571657,
          wei: 29.73763,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "沐川县",
          jing: 103.902335,
          wei: 28.956647,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "峨边彝族自治县",
          jing: 103.262048,
          wei: 29.230425,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "马边彝族自治县",
          jing: 103.546348,
          wei: 28.835521,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "峨眉山市",
          jing: 103.484504,
          wei: 29.601199,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "天城区",
          jing: 103.89528,
          wei: 30.798276,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "南充市",
          jing: 106.110698,
          wei: 30.837793,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "顺庆区",
          jing: 106.092399,
          wei: 30.796486,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "高坪区",
          jing: 106.118808,
          wei: 30.781623,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "嘉陵区",
          jing: 106.071793,
          wei: 30.758748,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "南部县",
          jing: 106.036584,
          wei: 31.347467,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "营山县",
          jing: 106.56542,
          wei: 31.076461,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "蓬安县",
          jing: 106.412151,
          wei: 31.029097,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "仪陇县",
          jing: 106.303042,
          wei: 31.271562,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "西充县",
          jing: 105.900878,
          wei: 30.995669,
        },
        {
          Mcity: "四川省",
          city: "阆中市",
          address: "阆中市",
          jing: 106.005047,
          wei: 31.558357,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "眉山市",
          jing: 103.848538,
          wei: 30.075439,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "东坡区",
          jing: 103.831752,
          wei: 30.042345,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "彭山区",
          jing: 103.87295,
          wei: 30.193056,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "仁寿县",
          jing: 104.134082,
          wei: 29.99563,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "洪雅县",
          jing: 103.372863,
          wei: 29.90489,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "丹棱县",
          jing: 103.512733,
          wei: 30.014448,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "青神县",
          jing: 103.846688,
          wei: 29.831358,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "宜宾市",
          jing: 104.643215,
          wei: 28.751768,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "翠屏区",
          jing: 104.644534,
          wei: 28.758563,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "宜宾县",
          jing: 104.533213,
          wei: 28.690045,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "长宁县",
          jing: 104.914158,
          wei: 28.577349,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "高县",
          jing: 104.518187,
          wei: 28.435036,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "珙县",
          jing: 104.713083,
          wei: 28.443674,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "屏山县",
          jing: 104.156008,
          wei: 28.708446,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "广安市",
          jing: 106.633212,
          wei: 30.455961,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "广安区",
          jing: 106.641608,
          wei: 30.474003,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "前锋区",
          jing: 106.893277,
          wei: 30.4963,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "岳池县",
          jing: 106.440114,
          wei: 30.537863,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "武胜县",
          jing: 106.295764,
          wei: 30.348772,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "邻水县",
          jing: 106.93038,
          wei: 30.334769,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "华蓥市",
          jing: 106.783088,
          wei: 30.390435,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "达州市",
          jing: 107.468023,
          wei: 31.209571,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "通川区",
          jing: 107.504517,
          wei: 31.214724,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "达川区",
          jing: 107.511845,
          wei: 31.196118,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "宣汉县",
          jing: 107.727191,
          wei: 31.353835,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "开江县",
          jing: 107.868736,
          wei: 31.082987,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "大竹县",
          jing: 107.204744,
          wei: 30.736266,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "渠县",
          jing: 106.972996,
          wei: 30.836659,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "万源市",
          jing: 108.034657,
          wei: 32.081631,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "雅安市",
          jing: 103.013261,
          wei: 29.980537,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "雨城区",
          jing: 103.033083,
          wei: 30.005447,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "名山区",
          jing: 103.109185,
          wei: 30.069954,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "荥经县",
          jing: 102.846738,
          wei: 29.792931,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "汉源县",
          jing: 102.645453,
          wei: 29.347187,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "石棉县",
          jing: 102.359462,
          wei: 29.227874,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "天全县",
          jing: 102.758317,
          wei: 30.066713,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "芦山县",
          jing: 102.92826,
          wei: 30.144084,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "宝兴县",
          jing: 102.814531,
          wei: 30.368126,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "巴中市",
          jing: 106.747477,
          wei: 31.867903,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "巴州区",
          jing: 106.768878,
          wei: 31.851478,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "恩阳区",
          jing: 106.655347,
          wei: 31.786691,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "通江县",
          jing: 107.245033,
          wei: 31.911705,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "南江县",
          jing: 106.828697,
          wei: 32.346589,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "平昌县",
          jing: 107.104008,
          wei: 31.560874,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "资阳市",
          jing: 104.627636,
          wei: 30.128901,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "雁江区",
          jing: 104.677096,
          wei: 30.10821,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "安岳县",
          jing: 105.335613,
          wei: 30.097246,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "乐至县",
          jing: 105.019916,
          wei: 30.275487,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "宜宾地区",
          jing: 104.643215,
          wei: 28.751768,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "南充地区",
          jing: 106.110698,
          wei: 30.837793,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "南充县",
          jing: 106.110698,
          wei: 30.837793,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "达川地区",
          jing: 107.511845,
          wei: 31.196118,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "达川市",
          jing: 107.511845,
          wei: 31.196118,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "巴中县",
          jing: 106.747477,
          wei: 31.867903,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "白沙工农区",
          jing: 104.160392,
          wei: 30.469654,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "雅安地区",
          jing: 103.013261,
          wei: 29.980537,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "阿坝藏族羌族自治州",
          jing: 102.224653,
          wei: 31.899413,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "马尔康市",
          jing: 102.206504,
          wei: 31.905813,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "马尔康区",
          jing: 102.206504,
          wei: 31.905813,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "汶川县",
          jing: 103.590387,
          wei: 31.476822,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "理县",
          jing: 103.166853,
          wei: 31.436473,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "茂县",
          jing: 103.853522,
          wei: 31.681154,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "松潘县",
          jing: 103.604698,
          wei: 32.655325,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "九寨沟县",
          jing: 104.243841,
          wei: 33.252056,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "金川县",
          jing: 102.063829,
          wei: 31.476277,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "小金县",
          jing: 102.364373,
          wei: 30.999031,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "黑水县",
          jing: 102.990108,
          wei: 32.061895,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "壤塘县",
          jing: 100.978526,
          wei: 32.265796,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "阿坝县",
          jing: 101.706655,
          wei: 32.902459,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "若尔盖县",
          jing: 102.961798,
          wei: 33.575892,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "红原县",
          jing: 102.544405,
          wei: 32.790891,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "甘孜藏族自治州",
          jing: 101.96231,
          wei: 30.04952,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "康定市",
          jing: 101.957146,
          wei: 29.998436,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "泸定县",
          jing: 102.234618,
          wei: 29.91416,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "丹巴县",
          jing: 101.890358,
          wei: 30.878577,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "九龙县",
          jing: 101.507294,
          wei: 29.000348,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "雅江县",
          jing: 101.014425,
          wei: 30.031533,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "道孚县",
          jing: 101.125237,
          wei: 30.979545,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "炉霍县",
          jing: 100.676372,
          wei: 31.39179,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "甘孜县",
          jing: 99.992671,
          wei: 31.622934,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "新龙县",
          jing: 100.311369,
          wei: 30.939169,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "德格县",
          jing: 98.580915,
          wei: 31.806118,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "白玉县",
          jing: 98.824182,
          wei: 31.209913,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "石渠县",
          jing: 98.1029,
          wei: 32.97896,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "色达县",
          jing: 100.332743,
          wei: 32.268129,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "理塘县",
          jing: 100.269818,
          wei: 29.996049,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "巴塘县",
          jing: 99.110712,
          wei: 30.004677,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "乡城县",
          jing: 99.798435,
          wei: 28.931172,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "稻城县",
          jing: 100.298403,
          wei: 29.037007,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "得荣县",
          jing: 99.286335,
          wei: 28.713037,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "凉山彝族自治州",
          jing: 102.267335,
          wei: 27.88161,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "西昌市",
          jing: 102.264449,
          wei: 27.894504,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "木里藏族自治县",
          jing: 101.280206,
          wei: 27.928835,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "盐源县",
          jing: 101.509188,
          wei: 27.422645,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "德昌县",
          jing: 102.17567,
          wei: 27.402839,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "会理县",
          jing: 102.244683,
          wei: 26.655026,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "会东县",
          jing: 102.577961,
          wei: 26.634669,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "宁南县",
          jing: 102.759634,
          wei: 27.066384,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "普格县",
          jing: 102.540901,
          wei: 27.376413,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "布拖县",
          jing: 102.811631,
          wei: 27.706192,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "金阳县",
          jing: 103.248772,
          wei: 27.696861,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "昭觉县",
          jing: 102.842611,
          wei: 28.014088,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "喜德县",
          jing: 102.412518,
          wei: 28.306726,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "冕宁县",
          jing: 102.17701,
          wei: 28.549657,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "越西县",
          jing: 102.50768,
          wei: 28.639801,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "甘洛县",
          jing: 102.771749,
          wei: 28.966069,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "美姑县",
          jing: 103.13218,
          wei: 28.32864,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "雷波县",
          jing: 103.571696,
          wei: 28.262683,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "广安地区",
          jing: 106.633212,
          wei: 30.455961,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "巴中地区",
          jing: 106.747477,
          wei: 31.867903,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "眉山地区",
          jing: 103.848538,
          wei: 30.075439,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "眉山县",
          jing: 103.848538,
          wei: 30.075439,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "资阳地区",
          jing: 104.627636,
          wei: 30.128901,
        },
      ],
    };
  },

  mounted() {
    this.initMap();
  },

  created() {
    var arr = [];
    for (let i = 0; i < this.cityData.length; i++) {
      var index = arr.findIndex((ele) => ele.label === this.cityData[i].city);
      if (index === -1) {
        arr.push({
          value: this.cityData[i].city,
          label: this.cityData[i].city,
          children: [
            {
              value: this.cityData[i].address,
              label: this.cityData[i].address,
            },
          ],
        });
      } else {
        arr[index].children.push({
          value: this.cityData[i].address,
          label: this.cityData[i].address,
        });
      }
      // if()
      // console.log(arr);
      this.options = arr;
    }
  },

  methods: {
    initMap() {
      //初始化地图
      this.map = new AMap.Map("container", {
        resizeEnable: true,
        zoom: 11, //级别
        zooms: [1, 18],
        center: [104.07,30.57], //中心点坐标
        viewMode: "3D", //使用3D视图
        lang: this.lang,
        mapStyle: "amap://styles/normal",
        infoWindow: null,
      });
      this.mouseTool = new AMap.MouseTool(this.map);
    },

    handleChange(value) {
      this.map.clearMap();

      var che = this.cityData.find((ele) => ele.address === value[1]);
      console.log(value, che);
      this.map.setCenter([che.jing, che.wei]); //设置地图中心点

      AMap.plugin("AMap.Weather", () => {
        var weather = new AMap.Weather();
        //查询实时天气信息, 查询的城市到行政级别的城市，如朝阳区、杭州市
        weather.getLive(value[1], (err, data) => {
          if (!err) {
            console.log("data", data);

            var str = [];
            str.push("<h4 >实时天气" + "</h4><hr>");
            str.push("<p>城市/区：" + data.city + "</p>");
            str.push("<p>城区编码：" + data.adcode + "</p>");

            str.push("<p>天气：" + data.weather + "</p>");
            str.push("<p>温度：" + data.temperature + "℃</p>");
            str.push("<p>风向：" + data.windDirection + "</p>");
            str.push("<p>风力：" + data.windPower + " 级</p>");
            str.push("<p>空气湿度：" + data.humidity + "</p>");
            str.push("<p>发布时间：" + data.reportTime + "</p>");
            var marker = new AMap.Marker({
              map: this.map,
              position: [che.jing, che.wei],
            });
            var infoWin = new AMap.InfoWindow({
              content:
                '<div class="info" style="position:inherit;margin-bottom:0;">' +
                str.join("") +
                '</div><div class="sharp"></div>',
              isCustom: true,
              offset: new AMap.Pixel(0, -37),
            });
            infoWin.open(this.map, marker.getPosition());
            marker.on("mouseover", () => {
              infoWin.open(this.map, marker.getPosition());
            });
          }
        });
        //未来4天天气预报
        weather.getForecast(value[1], (err, data) => {
          if (err) {
            return;
          }
          // 三天天气
          console.log("三天天气", data);
          // var str = [];
          // for (var i = 0,dayWeather; i < data.forecasts.length; i++) {
          //     dayWeather = data.forecasts[i];
          //     str.push(dayWeather.date+' <span class="weather">'+dayWeather.dayWeather+'</span> '+ dayWeather.nightTemp + '~' + dayWeather.dayTemp + '℃');
          // }
          // document.getElementById('forecast').innerHTML = str.join('<br>');
        });
      });
    },

    // end
  },
};
</script>

<style>
.btn {
  width: 6rem;
  margin: 0 1rem 0 4.5rem;
}

/* 弹框start */
html {
  font-size: 12px;
}
.amap-copyright {
  box-sizing: content-box;
}
* {
  box-sizing: border-box;
}
.input-textarea {
  color: grey;
  height: 8em;
  overflow: auto;
  border-radius: 0.4rem;
  border: 1px solid #ced4da;
  margin-bottom: 1rem;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
    "Segoe UI Symbol", "Noto Color Emoji";
  line-height: 1.5;
  font-weight: 300;
  color: #111213;
}

hr {
  margin: 0.5rem 0;
  box-sizing: content-box;
  height: 0;
  overflow: visible;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

p {
  margin-top: 0;
  margin-bottom: 0;
}

label {
  display: inline-block;
  margin-bottom: 0.4rem;
}

label,
.btn {
  margin-left: 0;
  font-size: 1rem;
}

button,
input,
select {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  overflow: visible;
  text-transform: none;
}

[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner,
button::-moz-focus-inner {
  padding: 0;
  border-style: none;
}

input[type="checkbox"],
input[type="radio"] {
  box-sizing: border-box;
  padding: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  padding: 0;
  margin: 0 0.5rem 0 0;
}

h4 {
  font-family: inherit;
  line-height: 1.8;
  font-weight: 300;
  color: inherit;
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.btn {
  display: inline-block;
  font-weight: 400;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  border: 1px solid transparent;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
    border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  background-color: transparent;
  background-image: none;
  color: #25a5f7;
  border-color: #25a5f7;
  padding: 0.25rem 0.5rem;
  line-height: 1.5;
  border-radius: 1rem;
  cursor: pointer;
}

.btn:hover {
  color: #fff;
  background-color: #25a5f7;
  border-color: #25a5f7;
}

.btn:hover {
  text-decoration: none;
}

.input-item {
  position: relative;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -ms-flex-align: center;
  align-items: center;
  width: 100%;
  height: 3rem;
}

.input-item:last-child {
  margin-bottom: 0;
}

.input-item > select,
.input-item > input[type="text"],
.input-item > input[type="date"] {
  position: relative;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  width: 1%;
  margin-bottom: 0;
}

.input-item > select:not(:last-child),
.input-item > input[type="text"]:not(:last-child),
.input-item > input[type="date"]:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-item > select:not(:first-child),
.input-item > input[type="text"]:not(:first-child),
.input-item > input[type="date"]:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-item-prepend {
  margin-right: -1px;
}

.input-item-text,
input[type="text"],
input[type="date"],
select {
  height: calc(2.2rem + 2px);
}

.input-item-text {
  width: 6rem;
  text-align: justify;
  padding: 0.4rem 0.7rem;
  display: inline-block;
  text-justify: distribute-all-lines;
  /*ie6-8*/
  text-align-last: justify;
  /* ie9*/
  -moz-text-align-last: justify;
  /*ff*/
  -webkit-text-align-last: justify;
  /*chrome 20+*/
  -ms-flex-align: center;
  align-items: center;
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #495057;
  text-align: center;
  white-space: nowrap;
  background-color: #e9ecef;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}

.input-item-text input[type="checkbox"],
.input-item-text input[type="radio"] {
  margin-top: 0;
}

.input-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
  border-radius: 0.25rem;
  width: 22rem;
  border-width: 0;
  border-radius: 0.4rem;
  box-shadow: 0 2px 6px 0 rgba(114, 124, 245, 0.5);
  position: fixed;
  top: 5rem;
  right: 1rem;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  padding: 0.75rem 1.25rem;
}

.input-text {
  line-height: 2rem;
  margin-right: 2rem;
}

.info hr {
  margin-right: 0;
  margin-left: 0;
  border-top-color: grey;
}

.info {
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: 0.25rem;
  position: fixed;
  top: 1rem;
  background-color: white;
  width: auto;
  min-width: 22rem;
  border-width: 0;
  right: 1rem;
  box-shadow: 0 2px 6px 0 rgba(114, 124, 245, 0.5);
}

.code {
  left: 1.5rem;
  right: 1.5rem;
  top: 1.5rem;
  bottom: 1.5rem;
  overflow: auto;
  margin-bottom: 0rem;
}

.code .btn {
  top: 1rem;
  position: absolute;
  right: 1rem;
}

.code .result {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  padding: 1rem;
  bottom: 1rem;
  position: absolute;
  top: 5.5rem;
  right: 1rem;
  left: 1rem;
  overflow: auto;
}

.code .status {
  color: #80adff;
  display: inline-block;
  font-size: 14px;
}

.code h4 {
  display: inline-block;
  max-width: 20rem;
  margin-right: 1rem;
  margin-bottom: 1rem;
}

select,
input[type="text"],
input[type="date"] {
  display: inline-block;
  width: 100%;
  padding: 0.375rem 1.75rem 0.375rem 0.75rem;
  line-height: 1.5;
  color: #495057;
  vertical-align: middle;
  background: #fff
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E")
    no-repeat right 0.75rem center;
  background-size: 8px 10px;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input[type="text"],
input[type="date"] {
  background: #fff;
  padding: 0.375rem 0.75rem;
}
/* select:focus */
select:focus,
input[type="text"]:focus,
input[type="date"]:focus {
  border-color: #80bdff;
  outline: 0;
  box-shadow: 0 0 0 0.1rem rgba(128, 189, 255, 0.1);
}

.btn:focus {
  outline: 0;
  box-shadow: none;
}
/* select:focus::-ms-value */
select:focus::-ms-value,
input[type="text"]:focus::-ms-value,
input[type="date"]:focus::-ms-value {
  color: #495057;
  background-color: #fff;
}


.native-toast {
  position: fixed;
  background-color: rgba(50, 50, 50, 0.8);
  border-radius: 33px;
  color: white;
  left: 50%;
  text-align: center;
  padding: 6px 12px;
  opacity: 0;
  z-index: 99999;
  transition: transform 0.25s, opacity 0.25s, top 0.25s;
  box-sizing: border-box;
}

.native-toast-bottom {
  bottom: 50px;
  -ms-transform: translateX(-50%) translateY(50px);
  transform: translateX(-50%) translateY(50px);
}

.native-toast-bottom.native-toast-shown {
  opacity: 1;
  -ms-transform: translateX(-50%) translateY(0);
  transform: translateX(-50%) translateY(0);
}

.native-toast-bottom.native-toast-edge {
  bottom: 0;
}

.native-toast-top {
  top: 50px;
  -ms-transform: translateX(-50%) translateY(-50px);
  transform: translateX(-50%) translateY(-50px);
}

.native-toast-top.native-toast-shown {
  opacity: 1;
  -ms-transform: translateX(-50%) translateY(0);
  transform: translateX(-50%) translateY(0);
}

.native-toast-top.native-toast-edge {
  top: 0;
}

.native-toast-center {
  top: 0;
  -ms-transform: translateX(-50%) translateY(-50px);
  transform: translateX(-50%) translateY(-50px);
}

.native-toast-center.native-toast-shown {
  opacity: 1;
  top: 50%;
  -ms-transform: translateX(-50%) translateY(-50%);
  transform: translateX(-50%) translateY(-50%);
}

.native-toast-edge {
  border-radius: 0;
  width: 100%;
  text-align: left;
}

@media screen and (min-width: 40rem) {
  .native-toast:not(.native-toast-edge) {
    max-width: 18rem;
  }
}

/*
  max-width does not seem to work in small screen?
*/

/*@media screen and (max-width: 768px) {
  .native-toast:not(.native-toast-edge) {
    max-width: 400px;
  }
}

@media screen and (max-width: 468px) {
  .native-toast:not(.native-toast-edge) {
    max-width: 300px;
  }
}*/

/* types */

.native-toast-error {
  background-color: #d92727;
  color: white;
}

.native-toast-success {
  background-color: #62a465;
  color: white;
}

.native-toast-warning {
  background-color: #fdaf17;
  color: white;
}

.native-toast-info {
  background-color: #5060ba;
  color: white;
}

[class^="native-toast-icon-"] {
  vertical-align: middle;
  margin-right: 8px;
}

[class^="native-toast-icon-"] svg {
  width: 16px;
  height: 16px;
}
/* 弹框end */
</style>
